#pragma once
#include <iostream>
#include <string>
using namespace std;

enum TaskStatus
{
    DIV_ZERO=1,
    MOD_ZERO,
    UNKOWN
};

char opStr[4] = {'+','-','*','/'};

class Task
{
public:
    Task(int a, int b, char op) : _a(a), _b(b), _op(op) {}

    void Run()
    {
        switch (_op)
        {
            case '+':
                _result = _a + _b;
                break;
            case '-':
                _result = _a - _b;
                break;
            case '*':
                _result = _a * _b;
                break;
            case '/':
                if (_b == 0)    _exitCode = DIV_ZERO;
                else    _result = _a / _b;
                break;
            case '%':
                if (_b == 0)    _exitCode = MOD_ZERO;
                else    _result = _a % _b;
                break;
            default:
                _exitCode = UNKOWN;
                break;
        }
    }

    string GetResult()
    {
        string resultStr;
        resultStr += to_string(_a);
        resultStr += _op;
        resultStr += to_string(_b);
        resultStr += '=';
        resultStr += to_string(_result);
        resultStr += "  ";
        if (_exitCode != 0)
        {
            resultStr += "error";
            resultStr += "  ";
            switch (_exitCode)
            {
                case DIV_ZERO:
                    resultStr += "div zero";
                    break;
                case MOD_ZERO:
                    resultStr += "mod zero";
                    break;
                case UNKOWN:
                    resultStr += "unkown";
                    break;
            }
        }
        else
            resultStr += "ok";
        return resultStr;
    }

    string GetTask()
    {
        string resultStr;
        resultStr += to_string(_a);
        resultStr += _op;
        resultStr += to_string(_b);
        resultStr += '=';
        resultStr += "???";
        return resultStr;
    }
    
private:
    int _a = 0;
    int _b = 0;
    char _op = ' ';
    int _exitCode = 0;
    int _result = 0;
};